//
//  SDefine.h
//  LSCodeLibrary
//
//  Created by Samuel on 12/14/15.
//  Copyright © 2015 Samuel. All rights reserved.
//

#ifndef SDefine_h
#define SDefine_h

#ifdef DEBUG
#define SLSCLOG 0
#else
#define SLSCLOG 0
#endif
/**
 *  DEBUG模式下打印日志
 */
#if SLSCLOG
#define SLog(fmt, ...) NSLog((@"\n方法名%s;\n行数：[Line %d];\n" fmt),__PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define SLog(fmt, ...)
#endif
#pragma mark 代码块
/**
 *  block
 */
#define ___WEAKSELF typeof(self) __weak weakSelf = self;
/**
 *  Alert
 */
#define ___showAlert(_TITLE,_MESSAGE) {UIAlertView *alert = [[UIAlertView alloc]initWithTitle:_TITLE message:_MESSAGE delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];[alert show];}

#pragma mark UI设置
/**
 *  获取屏幕 宽度、高度
 */
#define ___screenWidth ([UIScreen mainScreen].bounds.size.width)
#define ___screenHeight ([UIScreen mainScreen].bounds.size.height)
/**
 *  坐标设置
 */
#define ___left(_VIEW)     _VIEW.frame.origin.x
#define ___right(_VIEW)    _VIEW.frame.origin.x + CGRectGetWidth(_VIEW.frame)
#define ___top(_VIEW)      _VIEW.frame.origin.y
#define ___bottom(_VIEW)   _VIEW.frame.origin.y + CGRectGetHeight(_VIEW.frame)

#define ___setLeft(_VIEW,_FLOAT)   {CGRect frame = _VIEW.frame;    frame.origin.x = _FLOAT;                        _VIEW.frame = frame;}
#define ___setRight(_VIEW,_FLOAT)  {CGRect frame = _VIEW.frame;    frame.origin.x = _FLOAT - frame.size.width;     _VIEW.frame = frame;}
#define ___setTop(_VIEW,_FLOAT)    {CGRect frame = _VIEW.frame;    frame.origin.y = _FLOAT;                        _VIEW.frame = frame;}
#define ___setBottom(_VIEW,_FLOAT) {CGRect frame = _VIEW.frame;    frame.origin.y = _FLOAT - frame.size.height;    _VIEW.frame = frame;}

#define ___setSize(_VIEW,_W,_H)    {___setWidth(_VIEW,_W);         ___setHeight(_VIEW,_H);}
#define ___setWidth(_VIEW,_FLOAT)  {CGRect frame = _VIEW.frame;    frame.size.width = _FLOAT;                      _VIEW.frame = frame;}
#define ___setHeight(_VIEW,_FLOAT) {CGRect frame = _VIEW.frame;    frame.size.height = _FLOAT;                     _VIEW.frame = frame;}
#define ___width(_VIEW) CGRectGetWidth(_VIEW.frame)
#define ___height(_VIEW) CGRectGetHeight(_VIEW.frame)
#pragma mark 存储
/**
 *  userDefault 存储
 */
#define ___userDefault_get(_KEY) [[NSUserDefaults standardUserDefaults]objectForKey:_KEY]
#define ___userDefault_set(_KEY,_VALUE){ [[NSUserDefaults standardUserDefaults]setObject:_VALUE forKey:_KEY];[[NSUserDefaults standardUserDefaults]synchronize];}
#define ___userDefault_reset(_KEY){[[NSUserDefaults standardUserDefaults]removeObjectForKey:_KEY];[[NSUserDefaults standardUserDefaults]synchronize];}

#pragma mark 运算
/**
 *  由角度获取弧度 有弧度获取角度
 */
#define ___degreesToRadian(x) (M_PI * (x) / 180.0)
#define ___radianToDegrees(radian) (radian*180.0)/(M_PI)

#pragma mark 国际化
/**
 *  程序的本地化,引用国际化的文件
 */
#define ___myLocal(x, ...) NSLocalizedString(x, nil)


#pragma mark 颜色
/**
 *  rgb颜色转换（16进制->10进制）
 */
#define ___color_Value(rgbValue,a) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:a]
#define ___color_Clean [UIColor clearColor]
#define ___color_Rgb(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define ___color_Rgba(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]


#pragma mark 系统
/**
 *  获取系统版本
 */
#define ___ios_Version [[[UIDevice currentDevice] systemVersion] floatValue]
#define ___currentSystemVersion [[UIDevice currentDevice] systemVersion]
/**
 *  获取当前语言
 */
#define ___currentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
/**
 *  获取时间戳string
 */
#define ___getTimestamp [[NSDate dateWithTimeIntervalSinceNow:0] timeIntervalSince1970]


#endif /* SDefine_h */
